@import "../base/spacing";
@import "../utils/decorators";

.dropdown {
  position: relative;

  i {
    cursor: pointer;
  }

  &.open {

    .toggleable:not(.primary) {
      background: shade(@background-menu, 10%);
      box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);
      border-color: transparent;
      outline: 0;
    }
  }
}

.toggleable-container {

  .dropdown-items {
    display: none;
  }

  &.hover:hover,
  &.open {

    .dropdown-items {
      display: block;
    }
  }
}

.dropdown-items {
  &:extend(.dropdown-shadow);
  width: 270px;
  position: absolute;
  right: 0px;
  z-index: 3000;
  background: #fff;
  border: 1px solid #dadada;
  border-radius: 4px;

  .section {
    border-bottom: 1px solid rgba(0,0,0,.1);
    padding: 5px 0;
  }

  .section-header {
    padding: 2px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    &.light {
      color: @color-text--light;
      font-weight: 500;
    }
  }

  &.wide {
    width: 400px;
  }

  &.compact {

    .dropdown-item {
      padding: 2px 15px;
      border-bottom: 0;
    }

    .description {
      margin-left: 0;
    }

    hr {
      margin: 5px 0;
    }
  }

  &.roomy {

    .dropdown-item {
      padding: 10px 15px;
    }
  }

  &.no-border {

    .dropdown-item {
      border-bottom: 0;
    }
  }

  &.subtle-shadow {
    &:extend(.dropdown-shadow-subtle);
  }

  &.center {
    left: 50%;
    transform: translateX(-50%);
  }

  &.left {
    right: initial;
    left: 0;
  }

  &.over {
    top: 0;
  }

  &.top {
    bottom: ~"calc(100% + 5px)";
  }

  &.with-triangle:before {
    content: '';
    position: absolute;
    top: -8px;
    right: 10px;
    width: 12px;
    height: 12px;
    z-index: 3;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
  }

  &.with-triangle.left:before {
    left: 10px;
  }
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 5px 15px;
  border-bottom: 1px solid #eee;
  cursor: pointer;

  .fa-check-square {
    color: @blue;
  }

  .fa-check-square,
  .fa-square-o {
    font-size: 14px;
  }

  .fa-check {
    font-size: 11.5px;
  }

  * {
    cursor: pointer;
  }

  &:hover {
    background: #eee;

    i:not(.fa-check-square) {
      color: @color-text;
    }

    .description {
      color: @color-text;
    }
  }

  .fa, i {
    display: inline-block;
    width: 20px;
    color: rgba(0,0,0,.65);

    &.fa-i-cursor {
      // adjust positioning to center
      margin-left: 2px;
      margin-right: -2px;
    }
  }

  .btn .fa {
    color: inherit;
  }

  .label {
    font-weight: 500;
    margin-bottom: 3px;
  }

  .description {
    color: @color-text--muted;
    margin: 0;
    margin-left: 17px;

    &.small {
      font-size: 12.5px;
    }
  }

  &:first-of-type {
    border-radius: 2px 2px 0 0;
  }

  &:last-of-type {
    border-radius: 0 0 2px 2px;
  }
}